import { storeBindingsBehavior } from 'mobx-miniprogram-bindings'
import { store } from '../store/store'

Component({
  options:{
    styleIsolation: 'shared'
  },
  behaviors: [storeBindingsBehavior],
  storeBindings:{
    store,
    fields:{
      active: "activeTabBarIndex",
      sysHeight: "sysHeight"
    },
    actions:{
      updateActiveTabBar: 'updateActiveTabBarIndex'
    }
  },
  data: {
    tabberData: [
      {
        info: '',
        title: '美食',
        normal: '/images/food.png',
        active: '/images/food-active.png',
        pagePath: '/pages/food/food'
      },
      {
        info: '',
        title: "购物车",
        normal: "/images/cart.png",
        active: "/images/cart-active.png",
        pagePath: "/pages/cart/cart",
      },
      {
        info: '',
        title: '查看订单',
        normal: '/images/order.png',
        active: '/images/order-active.png',
        pagePath: '/pages/order/order'
      },
      {
        info: '',
        title: '个人中心',
        normal: '/images/user.png',
        active: '/images/user-active.png',
        pagePath: '/pages/user/user'
      }
    ],
  },

  methods: {
    // 页面跳转
    onChange(event) {
      // console.log(this.data.active)
      this.updateActiveTabBar(event.detail);
      wx.switchTab({
        url: this.data.tabberData[event.detail].pagePath,
      })
    },
  },
})